package de.islanders.shared;

import java.util.concurrent.CountDownLatch;

public class CastBar implements Runnable {
	private int duration;
	private CountDownLatch cdl;

	public CastBar(int duration, CountDownLatch cdl) {
		this.duration = duration;
		this.cdl = cdl;
	}

	/**
	 * @return the duration
	 */
	public int getDuration() {
		return duration;
	}


	/**
	 * @param duration the duration to set
	 */
	public void setDuration(int duration) {
		this.duration = duration;
	}

	public void run() {
		try{
			for(int i = duration; i >= 0; i--) {
				System.out.println(i); //TODO replace system.out with something castbar like and/or something chatlog like
				Thread.sleep(1000);
			}
			cdl.countDown();
		} catch(InterruptedException e) {
			e.printStackTrace();
		}
	}
}
